<template>
    <div class="roomType">
        <div class="roomType_tit">
            <NavBar :tit="'户型筛选'"></NavBar>
        </div>
        <div class="roomType_houseCont">
            <HouseCont></HouseCont>
        </div>
        <div class="roomType_type">
            <div class="buyHouse_type">
                <h3>买房选型</h3>
                <div class="buyHouse_select_type">
                    <p :class="buyHouse.currentIndex === ind ? 'active' : '' " v-for="(k,ind) in buyHouse.houseSelect" :key="ind"  @click="selectTag(k,ind)" >{{k.title}}</p>
                </div>
            </div>

            <div class="buyHouse_roomType">
                <h3>户型</h3>
                <div class="buyHouse_select_roomType">
                    <p :class="buyHouse.roomIndex === i ? 'roomActive' : '' " v-for="(v,i) in buyHouse.houseType" :key="i" @click="roomSelect(v,i)">{{v.title}}</p>
                </div>
            </div>
        </div>
        <div class="roomType_sure">
            <HouseSure :tit="'户型筛选'" :select="select"></HouseSure>
        </div>
    </div>
</template>

<script>
import { defineComponent , ref , onMounted, reactive} from 'vue'
export default defineComponent({
  setup(props,context) {
     
        const buyHouse = reactive({
            houseSelect:[
                {
                    'title':'不限'
                },
                {
                    'title':'新房'
                },
                {
                    'title':'二手房'
                }
            ],
            houseType:[
                {
                    'title':'不限'
                },
                {
                    'title':'1室'
                },
                {
                    'title':'2室'
                },
                {
                    'title':'3室'
                },
                {
                    'title':'3室+'
                },
            ],
            currentIndex:'',
            roomIndex:'',
            
        })

        const select = reactive({
            houseTy:'',
            roomTy:'',
        })


        // 选择房型
        const selectTag = (title,index) => {
            
            buyHouse.currentIndex = index;
            select.houseTy = title;
        }

        // 选择户型
        const roomSelect = (title,index) => {
            buyHouse.roomIndex = index;
            select.roomTy = title;
        }

        return {
            buyHouse,
            select,
            selectTag,
            roomSelect,
        }
  },
})
</script>

<style lang='less'>
.roomType{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    .roomType_tit{
        width: 100%;
        height: 60px;
    }
    .roomType_houseCont{
        width: 100%;
    }
    .roomType_type{
        flex: 1;
        padding: 0 30px;
        .buyHouse_type{
            width: 100%;
            height: auto;
            text-align: center;
            margin-top: 50px;
            h3{
                font-size: 17px;
                color: #999999;
            }
            .buyHouse_select_type{
                width: 100%;
                margin: 0 auto;
                height: auto;
                margin-top: 28px;
                display: flex;
                .active{
                    color: #fff;
                    background: #f19e39;
                }
                p:first-child{
                    margin-left: 16px;
                }
                p{
                    width: 86px;
                    height: 30px;
                    margin-right: 12px;
                    color: #999999;
                    font-size: 15px;
                    background: #faf7f8;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
            }
        }

        .buyHouse_roomType{
            width: 100%;
            height: auto;
            text-align: center;
            margin-top: 50px;
            h3{
                font-size: 17px;
                color: #999999;
            }
            .buyHouse_select_roomType{
                width: 100%;
                margin: 0 auto;
                height: auto;
                margin-top: 28px;
                display: flex;
                flex-wrap: wrap;
                justify-content: space-between;
                .roomActive{
                    color: #fff;
                    background: #f19e39;
                }
                p{
                    width: 70px;
                    height: 30px;
                    color: #999999;
                    font-size: 15px;
                    background: #faf7f8;
                    margin-bottom: 15px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
                p:nth-child(4){
                    margin-right: 0;
                }
            }
            
        }
    }
    .roomType_sure{
        width: 100%;
        height: 64px;
    }
    
}
</style>
